<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="/admin/lib/respond.min.js"></script>
<![endif]-->
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.css" />
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
    <link href="/admin/lib/select2/4.0.7/css/select2.min.css" rel="stylesheet" />
    <!--[if IE 6]>
<script type="text/javascript" src="/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title></title>

</head>

<body>
    <article class="page-container">
        <form class="form form-horizontal" id="form" autocomplete="off" >
            <div class="row cl">
                <label class="form-label col-sm-3">样品类型：</label>
                <label class="form-label col-sm-9" style="text-align: left;"> {{ $data_rel->toolname }}</label>
                {{-- <input type="hidden" name="tool_id" value="{{ $data_rel->tool_id }}"> --}}
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">检验标准：</label>
                <label class="form-label col-sm-9" style="text-align: left;"> {{ $data_rel->num }}</label>
                {{-- <input type="hidden" name="std_id" value="{{ $data_rel->std_id }}"> --}}
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">检验项目：</label>
                <label class="form-label col-sm-9" style="text-align: left;"> {{ $data_rel->itemname }}</label>
                {{-- <input type="hidden" name="item_id" value="{{ $data_rel->testitem_id }}"> --}}
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">额定电压/分类：</label>
                <div class="formControls col-sm-9">
                    <select class="select2" name="vol_class_id" style="width: 200px">
                        <option value="0">无关</option>
                        @foreach($data_vol_class as $val)
                        <option value="{{$val -> id}}">{{$val -> val}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">{{ $data_rel->key }}：</label>
                <div class="formControls col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" name="val" style="width:100px">　{{ $data_rel->unit }}
                </div>
            </div>
            {{csrf_form_field()}}
            @csrf

            <div class="row cl">
                <div class="col-sm-9 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>

        <div class="mt-15">
            <table class="table table-border table-bordered table-hover table-bg table-responsive table-condensed">
                <thead>
                    <tr class="text-c">
                        <th>ID</th>
                        <th>额定电压/分类</th>
                        <th>{{ $data_rel->key }}（{{ $data_rel->unit }}）</th>
                        {{-- <th width="100px">排序</th> --}}
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($data as $val)
                        <tr class="text-c">
                            <td>{{ $val->id }}</td>
                            <td>{{ $val->vol_class_val === null ? '/' : $val->vol_class_val }}</td>
                            <td>{{ $val->condition_val }}</td>
                            <td>
                                <a href="javascript:;" onclick="del(this,{{ $val->id }})" class="ml-5 btn btn-danger-outline radius size-MINI" >删除</a>
                            </td>
                        </tr>
                    @endforeach
                    
                </tbody>
                @csrf
            </table>
        </div>
    </article>
    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="/admin/lib/layer/3.1.1/layer.js"></script>
    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
    <!--/_footer 作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script src="/admin/lib/select2/4.0.7/js/select2.min.js"></script>

    <script type="text/javascript">
        $(function(){
            
            var index2;

            $('.select2').select2();

            $("#form").validate({
                rules:{
                   val:{
                        required:true,
                        notSpace:true,
                    },
                },
                // onkeyup:false,
                // focusCleanup:false,
                success:"valid",
                submitHandler:function(form){
                   $(form).ajaxSubmit({ 
                        type: 'post', 
                        url: "",//自己提交给自己可以不写url   
                        beforeSend : function () {
                            //0.4透明度 白色遮罩
                           index2 = layer.load(2,{ shade: [0.3,'#fff'] }); 
                        },
                        complete : function () { 
                            layer.close(index2); 
                        },
                        success: function(data) {
                            //判断添加结果 
                            if(data === '1'){ 
                                window.location.reload();//刷新
                                parent.layer.msg('添加成功!',{ icon: 1, time:2000 });
                            }else if(data === '2'){ 
                                layer.msg('已存在相同的记录!',{ icon: 2, time:5000 });
                            }
                            else{
                                layer.msg('操作失败!', { icon: 2, time: 2000 }); 
                            } 
                        }, 
                        error: function(data) {
                            console.log(data);
                            ajax_error(data);
                        }///error---end
                    }); 
                }
            });
        });

        /*删除*/
        function del(obj,id){
            var index2;

            layer.confirm('确认要删除吗？',function(index){
                $.ajax({
                    type: 'GET',
                    url: '/{{config('constant.name_admin')}}/condition/del' + '?id=' + id,
                    // dataType: 'json',
                    success: function(data){
                        // console.log(data);
                        if(data === '1'){
                            $(obj).parents("tr").remove();
                            layer.msg('删除成功!',{icon:1,time:2000});
                        }else{
                            layer.msg('删除失败!',{icon:2,time:2000});
                        }
                    },
                    error:function(data) {
                        ajax_error(data);
                    },
                    beforeSend : function () { 
                        //0.4透明度 白色遮罩
                        index2 = layer.load(2,{ shade: [0.05,'#000'] }); 
                    },
                    complete : function () { 
                        layer.close(index2); 
                    },
                });		
            });
        }

        /*关联xxx*/
        function rel_xxx(title,url,id,w,h){
            layer_show(title,url + '?id=' + id,w,h);
        }
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
</body>

</html>